#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

char cmd[100][119];

int file_open(const char* file_name)
{
    int fd = open(file_name, O_RDONLY);
    if(fd < 0) {
        perror("open file error");
        return -1;
    }

    return fd;
}



int file_handle(int fd)
{
    char *locate;
    int i;
    char buf[1024 * 10];

    read(fd, buf, sizeof(buf));
    locate = strstr(buf, "G0000");

    for(i = 0; i < 77; i++) {
        memcpy(cmd[i], locate, 118);
        locate += 120;
    }

    //printf("%s\r\n", cmd[0]);
    return 0;
}
